# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=kmymoney
pkgver=5.1.2
pkgrel=3
# armhf blocked by extra-cmake-modules
# s390x and riscv64 blocked by polkit -> kio
# armhf, ppc64le, s390x, riscv64 blocked by qt5-qtwebengine
arch="all !armhf !ppc64le !s390x !riscv64"
url="https://kmymoney.org/"
pkgdesc="Personal finance manager for KDE which operates similarly to MS-Money or Quicken"
license="GPL-2.0-or-later"
makedepends="
	akonadi-dev
	alkimia-dev
	doxygen
	extra-cmake-modules
	gpgme-dev
	kactivities-dev
	karchive-dev
	kcmutils-dev
	kcompletion-dev
	kconfig-dev
	kconfigwidgets-dev
	kcontacts-dev
	kcoreaddons-dev
	kdiagram-dev
	kdoctools-dev
	kholidays-dev
	ki18n-dev
	kiconthemes-dev
	kidentitymanagement-dev
	kio-dev
	kitemmodels-dev
	kitemviews-dev
	knotifications-dev
	kservice-dev
	ktextwidgets-dev
	kwallet-dev
	kxmlgui-dev
	qt5-qtbase-dev
	qt5-qtsvg-dev
	qt5-qtwebengine-dev
	samurai
	"
checkdepends="xvfb-run"
source="https://download.kde.org/stable/kmymoney/$pkgver/src/kmymoney-$pkgver.tar.xz
	Fix-Compile-for-Newer-Akonadi-Builds.patch"
subpackages="$pkgname-doc $pkgname-lang"

case $CARCH in
	aarch64) options="!check";; # Segfault / child aborted errors on 3-12 builder
esac

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DENABLE_WEBENGINE=ON
	cmake --build build
}

check() {
	cd build
	# reports-chart-test requires OpenGL
	# csvimport-csvdate-test is broken
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest -E "(reports-chart|csvimport-csvdate)-test"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
38c60998be4e3ffb49091eb2085b293c2d5265f6582e980d2dc60a66a00862b6afd3e2152c752a9fb14a7bf8b6255a0c39b69b65e2f5c976f23d965e3a1cdf46  kmymoney-5.1.2.tar.xz
e27c403462c0714df956bb477628d0920d13a952e25c83eaa6da2e8cb67d6193bbd1088c185f9ace9527fdb0fc25a598d0e816baf0e8a961e4e90cf5f2d3fa51  Fix-Compile-for-Newer-Akonadi-Builds.patch
"
